package Pattern;

import java.util.Vector;

public class Pattern 
{
	Vector<Vector<PatternNode>> patternVec = new Vector<Vector<PatternNode>>();
	
	
	
	public Pattern () {}
	
	
	
	public Pattern (PatternNode ipatternRoot)
	{
		Vector<PatternNode> root = new Vector<PatternNode>();
		root.add(ipatternRoot);
		this.patternVec.add(root);
	}
	
	
	public Pattern (Vector<Vector<PatternNode>> ipatternVec)
	{
		this.patternVec = ipatternVec;
	}
	
	
	public Vector<Vector<PatternNode>> getPatternVec()
	{
		return patternVec;
	}



	public void setPatternVec(Vector<PatternNode> ... ipattern) 
	{
		for (Vector<PatternNode> vector : ipattern) 
		{
			this.patternVec.add(vector);
		}
	}
	
	
	public int getSize() 
	{
		int size = 0;
		for (Vector<PatternNode> vector : this.patternVec) 
		{
			size += vector.size();
		}
		
		return size;
	}
	
	
	public String toString ()
	{
		String retVal = "";
		int i = 1;
		for (Vector<PatternNode> patternVec : this.patternVec) 
		{
			retVal += "Layer " + i++ + ": " + patternVec.toString() + "\n"; 
		}
		
		return retVal;
	}
	
	
	/*************************************************************************************************************/
	/** Title: Renaming																				
	/** Description: renames all atoms in the pattern 			
	/*************************************************************************************************************/
	
	public void Renaming ()
	{
		int cnt = 1;
		for (Vector<PatternNode> vector : patternVec) 
		{
			if (false == patternVec.lastElement().equals(vector)) 
			{
				for (PatternNode PatternNode2 : vector) 
				{
					PatternNode2.setNewName(PatternNode2.getName() + cnt++);
				}
			}
			
			else
			{
				for (PatternNode PatternNode2 : vector) 
				{
					PatternNode2.setNewName(PatternNode2.getName());
				}
			}
		}
	}

}
